<template>
  <div>
    <!-- 查看施组(方案)审批计划表 -->
    <searchData :search-data="searchArr" @search="search" />
    <list-table
      ref="table"
      tableLayout="fixed"
      size="default"
      rowKey="id"
      :columns="columns"
      :request="loadData"
      :page-keys="['pageNo', 'pageSize', 'totalSize']"
      :alert="true"
      show-size-changer
      show-quick-jumper
      showPagination="auto"
    >
    </list-table>
  </div>
</template>
<script>
import { detailsQueryList } from '@/api/technical/approval'
import { listOption } from '@/api/technical/approvalPlan'
import { thistle } from 'color-name'
import Selector from '@/components/Select/Selector' // 枚举值
const columns = [
  { title: '施组(方案)名称', dataIndex: 'schemeName' },
  { title: '方案类型', dataIndex: 'schemeCategory' },
  { title: '计划编制人', dataIndex: 'preparedUserName' },
  { title: '计划报审时间', dataIndex: 'planReviewTime' },
  { title: '要求审批完成时间', dataIndex: 'reviewEndTime' },
  { title: '审批其他需求', dataIndex: 'reviewOtherRequirements' },
  { title: '状态', dataIndex: 'approvalManagementStatusStr' },
  { title: '变更原因',dataIndex: 'changeDetailReason',},
]

export default {
  props: {
    reqObj:{
      type: Object,
      default() {
        return {}
      }
    },
  },
  data() {
    return {
      dataList: [],
      columns,
      selectedRowKeys: [],
      selectionRows: [],
      searchTypeList:[]
    }
  },
  watch:{
    ['reqObj.businessVersion']:{
          handler(newValue, oldValue){
            let that = this;
            setTimeout(()=>{
              that.$refs?.table?.refresh(true)
            })
          },
          deep: true,
          immediate:true,
       }
  },
  computed: {
    searchArr() {
      return [
        { name: '方案名称', type: 'input', value: 'constructionName' },
        {name: '方案类型',value: 'planType',type: 'select',data: this.searchTypeList,},
        {
          name: '计划报审时间',
          type: 'dateRange',
          value: 'monitoringTime',
          attr: {
            rangeFormat: ['planReviewTimeBegin', 'planReviewTimeEnd']
          }
        },
        {
          name: '要求完成审批时间',
          type: 'dateRange',
          value: 'monitoringTime2',
          attr: {
            rangeFormat: ['reviewEndTimeBegin', 'reviewEndTimeEnd']
          }
        },
        { name: '计划编制人', type: 'input', value: 'preparedUserName' }
      ]
    },
    newreqObj(){
      return this.reqObj;
    },
  },
  mounted(){
    this.listOptionFn();
  },
  methods: {
     loadData(parameter) {
      try {
        if(this.reqObj.planId && this.reqObj.businessVersion){
          const requestParameters = Object.assign({}, parameter, this.queryParam,this.reqObj)
        return detailsQueryList(requestParameters).then((res) => {
          return res
        })
        }


      } catch (error) {
        console.log(error)
      }
    },
    listOptionFn() {
      listOption({ type: '5' }).then((res) => {
        this.typeOption = res.data;
        if(this.typeOption.length){
          this.typeOption.map((item)=>{
            item.label = item.name;
            item.value = item.id;
          })
        }
        this.searchTypeList = this.typeOption;
      })

    },
    // 搜索
    search(value) {
      value && (this.queryParam = value)
      this.$refs.table.refresh(true)
    },
  }
}
</script>